Ext.namespace('system.Role');
system.Role.fields=[];
system.Role.className="com.wef.system.entity.Role";	
var length=0;

length=system.Role.fields.length;
system.Role.fields[length]={};
system.Role.fields[length].fieldName="roleId";
system.Role.fields[length].dataType="String";
system.Role.fields[length].length=50;  
system.Role.fields[length].scale=-1; 
system.Role.fields[length].allowEdit=false; 
system.Role.fields[length].allowNull=false; 
system.Role.fields[length].defaultValue=""; 
system.Role.fields[length].displayInForm=false; 
system.Role.fields[length].displayInList=false; 
system.Role.fields[length].displayInQuery=false; 


length=system.Role.fields.length;
system.Role.fields[length]={};
system.Role.fields[length].fieldName="roleName";
system.Role.fields[length].dataType="String";
system.Role.fields[length].length=50;  
system.Role.fields[length].scale=-1; 
system.Role.fields[length].allowEdit=false; 
system.Role.fields[length].allowNull=false; 
system.Role.fields[length].validators={maxLength : 50};
system.Role.fields[length].defaultValue=""; 
system.Role.fields[length].displayInForm=true; 
system.Role.fields[length].displayInList=true; 
system.Role.fields[length].displayInQuery=true; 


length=system.Role.fields.length;
system.Role.fields[length]={};
system.Role.fields[length].fieldName="roleDesc";
system.Role.fields[length].dataType="String";
system.Role.fields[length].length=100;  
system.Role.fields[length].scale=-1; 
system.Role.fields[length].allowEdit=false; 
system.Role.fields[length].allowNull=true; 
system.Role.fields[length].validators={maxLength : 100};
system.Role.fields[length].defaultValue=""; 
system.Role.fields[length].displayInForm=true; 
system.Role.fields[length].displayInList=true; 
system.Role.fields[length].displayInQuery=true; 

length=system.Role.fields.length;
system.Role.fields[length]={};
system.Role.fields[length].fieldName="activeDate";
system.Role.fields[length].dataType="java.util.Date";
system.Role.fields[length].length=-1;  
system.Role.fields[length].scale=-1; 
system.Role.fields[length].allowEdit=false; 
system.Role.fields[length].allowNull=false; 
system.Role.fields[length].defaultValue=""; 
system.Role.fields[length].displayInForm=true; 
system.Role.fields[length].displayInList=true; 
system.Role.fields[length].displayInQuery=false; 


length=system.Role.fields.length;
system.Role.fields[length]={};
system.Role.fields[length].fieldName="expiredDate";
system.Role.fields[length].dataType="java.util.Date";
system.Role.fields[length].length=-1;  
system.Role.fields[length].scale=-1; 
system.Role.fields[length].allowEdit=false; 
system.Role.fields[length].allowNull=false; 
system.Role.fields[length].defaultValue=""; 
system.Role.fields[length].displayInForm=true; 
system.Role.fields[length].displayInList=true; 
system.Role.fields[length].displayInQuery=false; 


length=system.Role.fields.length;
system.Role.fields[length]={};
system.Role.fields[length].fieldName="roleType";
system.Role.fields[length].dataType="String";
system.Role.fields[length].length=20;  
system.Role.fields[length].scale=-1; 
system.Role.fields[length].allowEdit=false; 
system.Role.fields[length].allowNull=true; 
system.Role.fields[length].validators={maxLength : 20};
system.Role.fields[length].defaultValue=""; 
system.Role.fields[length].displayInForm=true; 
system.Role.fields[length].displayInList=true; 
system.Role.fields[length].displayInQuery=false; 


length=system.Role.fields.length;
system.Role.fields[length]={};
system.Role.fields[length].fieldName="createdByUser";
system.Role.fields[length].dataType="String";
system.Role.fields[length].length=10;  
system.Role.fields[length].scale=-1; 
system.Role.fields[length].allowEdit=false; 
system.Role.fields[length].allowNull=true; 
system.Role.fields[length].defaultValue=""; 
system.Role.fields[length].displayInForm=false; 
system.Role.fields[length].displayInList=false; 
system.Role.fields[length].displayInQuery=false; 


length=system.Role.fields.length;
system.Role.fields[length]={};
system.Role.fields[length].fieldName="createdDtmLoc";
system.Role.fields[length].dataType="java.util.Date";
system.Role.fields[length].length=-1;  
system.Role.fields[length].scale=-1; 
system.Role.fields[length].allowEdit=false; 
system.Role.fields[length].allowNull=true; 
system.Role.fields[length].defaultValue=""; 
system.Role.fields[length].displayInForm=false; 
system.Role.fields[length].displayInList=false; 
system.Role.fields[length].displayInQuery=false; 


length=system.Role.fields.length;
system.Role.fields[length]={};
system.Role.fields[length].fieldName="createdTimeZone";
system.Role.fields[length].dataType="String";
system.Role.fields[length].length=10;  
system.Role.fields[length].scale=-1; 
system.Role.fields[length].allowEdit=false; 
system.Role.fields[length].allowNull=true; 
system.Role.fields[length].defaultValue=""; 
system.Role.fields[length].displayInForm=false; 
system.Role.fields[length].displayInList=false; 
system.Role.fields[length].displayInQuery=false; 


length=system.Role.fields.length;
system.Role.fields[length]={};
system.Role.fields[length].fieldName="updatedByUser";
system.Role.fields[length].dataType="String";
system.Role.fields[length].length=10;  
system.Role.fields[length].scale=-1; 
system.Role.fields[length].allowEdit=false; 
system.Role.fields[length].allowNull=true; 
system.Role.fields[length].defaultValue=""; 
system.Role.fields[length].displayInForm=false; 
system.Role.fields[length].displayInList=false; 
system.Role.fields[length].displayInQuery=false; 


length=system.Role.fields.length;
system.Role.fields[length]={};
system.Role.fields[length].fieldName="updatedDtmLoc";
system.Role.fields[length].dataType="java.util.Date";
system.Role.fields[length].length=-1;  
system.Role.fields[length].scale=-1; 
system.Role.fields[length].allowEdit=false; 
system.Role.fields[length].allowNull=true; 
system.Role.fields[length].defaultValue=""; 
system.Role.fields[length].displayInForm=false; 
system.Role.fields[length].displayInList=false; 
system.Role.fields[length].displayInQuery=false; 


length=system.Role.fields.length;
system.Role.fields[length]={};
system.Role.fields[length].fieldName="updatedTimeZone";
system.Role.fields[length].dataType="String";
system.Role.fields[length].length=10;  
system.Role.fields[length].scale=-1; 
system.Role.fields[length].allowEdit=false; 
system.Role.fields[length].allowNull=true; 
system.Role.fields[length].defaultValue=""; 
system.Role.fields[length].displayInForm=false; 
system.Role.fields[length].displayInList=false; 
system.Role.fields[length].displayInQuery=false; 


length=system.Role.fields.length;
system.Role.fields[length]={};
system.Role.fields[length].fieldName="recordVersion";
system.Role.fields[length].dataType="Long";
system.Role.fields[length].length=10;  
system.Role.fields[length].scale=0; 
system.Role.fields[length].allowEdit=false; 
system.Role.fields[length].allowNull=false; 
system.Role.fields[length].defaultValue=""; 
system.Role.fields[length].displayInForm=false; 
system.Role.fields[length].displayInList=false; 
system.Role.fields[length].displayInQuery=false; 


length=system.Role.fields.length;
system.Role.fields[length]={};
system.Role.fields[length].fieldName="createdOffice";
system.Role.fields[length].dataType="String";
system.Role.fields[length].length=5;  
system.Role.fields[length].scale=-1; 
system.Role.fields[length].allowEdit=false; 
system.Role.fields[length].allowNull=true; 
system.Role.fields[length].defaultValue=""; 
system.Role.fields[length].displayInForm=false; 
system.Role.fields[length].displayInList=false; 
system.Role.fields[length].displayInQuery=false; 


length=system.Role.fields.length;
system.Role.fields[length]={};
system.Role.fields[length].fieldName="updatedOffice";
system.Role.fields[length].dataType="String";
system.Role.fields[length].length=5;  
system.Role.fields[length].scale=-1; 
system.Role.fields[length].allowEdit=false; 
system.Role.fields[length].allowNull=true; 
system.Role.fields[length].defaultValue=""; 
system.Role.fields[length].displayInForm=false; 
system.Role.fields[length].displayInList=false; 
system.Role.fields[length].displayInQuery=false; 


length=system.Role.fields.length;
system.Role.fields[length]={};
system.Role.fields[length].fieldName="officeCode";
system.Role.fields[length].dataType="String";
system.Role.fields[length].length=5;  
system.Role.fields[length].scale=-1; 
system.Role.fields[length].allowEdit=false; 
system.Role.fields[length].allowNull=false; 
system.Role.fields[length].defaultValue=""; 
system.Role.fields[length].displayInForm=true; 
system.Role.fields[length].displayInList=false; 
system.Role.fields[length].displayInQuery=false; 
system.Role.fields[length].display={};
system.Role.fields[length].display.displayType="combo";
var officeDs = new Ext.data.Store({
	proxy : new Gfa.data.DwrProxy(CommonService),
	reader : new Gfa.data.DwrReader({}, ['officeCode', 'officeName']),
	pruneModifiedRecords : true,
	remoteSort : false
});
var cmOffice = new Ext.grid.ColumnModel([{
	header : system.Office.officeName,
	dataIndex : 'officeName',
	width : 250
}]);
var itemObject ={
	xtype : 'gfaCombobox',
	name : 'officeCode',
	fieldLabel : '办事处',
	store : officeDs,
	cm : cmOffice,
	displayField : 'officeName',
	valueField : 'officeCode',
	listType : 'grid',
	listWidth : 250,
	maxHeight : 400,
	pageSize : 15,
	//matchType : 'likeanywhere',
	queryObjectName : 'com.wef.system.entity.Office',
	orderByProps : {
		'officeName' : 'asc'
	},
	triggerAction : 'all',
	emptyText : '请选择...',
	selectOnFocus : true,
	forceSelection : true,
	anchor : '-10'
};
system.Role.fields[length].display.itemObject=itemObject;

length=system.Role.fields.length;
system.Role.fields[length]={};
system.Role.fields[length].fieldName="officeId";
system.Role.fields[length].dataType="String";
system.Role.fields[length].length=50;  
system.Role.fields[length].scale=-1; 
system.Role.fields[length].allowEdit=false; 
system.Role.fields[length].allowNull=false; 
system.Role.fields[length].defaultValue=""; 
system.Role.fields[length].displayInForm=false; 
system.Role.fields[length].displayInList=false; 
system.Role.fields[length].displayInQuery=false;

length=system.Role.fields.length;
system.Role.fields[length]={};
system.Role.fields[length].fieldName="activeFlag";
system.Role.fields[length].dataType="Boolean";
system.Role.fields[length].length=1;  
system.Role.fields[length].scale=0; 
system.Role.fields[length].allowEdit=false; 
system.Role.fields[length].allowNull=true; 
system.Role.fields[length].defaultValue=""; 
system.Role.fields[length].displayInForm=true; 
system.Role.fields[length].displayInList=false; 
system.Role.fields[length].displayInQuery=false; 
system.Role.fields[length].display={};
system.Role.fields[length].display.displayType="checkbox";

length=system.Role.fields.length;
system.Role.fields[length]={};
system.Role.fields[length].fieldName="deletedFlag";
system.Role.fields[length].dataType="Boolean";
system.Role.fields[length].length=1;  
system.Role.fields[length].scale=0; 
system.Role.fields[length].allowEdit=false; 
system.Role.fields[length].allowNull=true; 
system.Role.fields[length].defaultValue=""; 
system.Role.fields[length].displayInForm=true; 
system.Role.fields[length].displayInList=false; 
system.Role.fields[length].displayInQuery=false; 
system.Role.fields[length].display={};
system.Role.fields[length].display.displayType="checkbox";


length=system.Role.fields.length;
system.Role.fields[length]={};
system.Role.fields[length].fieldName="canQueryallFlag";
system.Role.fields[length].dataType="Boolean";
system.Role.fields[length].length=1;  
system.Role.fields[length].scale=0; 
system.Role.fields[length].allowEdit=false; 
system.Role.fields[length].allowNull=true; 
system.Role.fields[length].defaultValue=""; 
system.Role.fields[length].displayInForm=true; 
system.Role.fields[length].displayInList=false; 
system.Role.fields[length].displayInQuery=false; 
system.Role.fields[length].display={};
system.Role.fields[length].display.displayType="checkbox";

length=system.Role.fields.length;
system.Role.fields[length]={};
system.Role.fields[length].fieldName="isVirtualFlag";
system.Role.fields[length].dataType="Boolean";
system.Role.fields[length].length=1;  
system.Role.fields[length].scale=0; 
system.Role.fields[length].allowEdit=false; 
system.Role.fields[length].allowNull=true; 
system.Role.fields[length].defaultValue=""; 
system.Role.fields[length].displayInForm=true; 
system.Role.fields[length].displayInList=false; 
system.Role.fields[length].displayInQuery=false; 
system.Role.fields[length].display={};
system.Role.fields[length].display.displayType="checkbox";


RoleManager = function(){
	this.doLayout();
};

Ext.extend(RoleManager, Gfa.view.BaseSingleView, {
	initData : function(){
		this.entityConfig = system.Role;
		this.dwrService = RoleService;
		this.dwrMethod = 'saveOrUpdateRoles';
		this.popupWidth = 550;
		this.popupHeight = 230;
	},
	
	buildEditComposite : function(){
		return Gfa.FormHelper.buildEditForm(this.entityConfig, this);
	},
	
	saveAction : function() {		
		var activeDate = this.frmPopup.form.findField('activeDate').getValue();
		var expiredDate = this.frmPopup.form.findField('expiredDate').getValue();
		if (activeDate > expiredDate) {
			Ext.Msg.alert('提示', '生效日期不得大于失效日期!');
			return false;
		}
		RoleManager.superclass.saveAction.call(this);
	},

	onPopupShow : function() {
		var officeCode = this.frmPopup.form.findField('officeCode');
		CommonService.findByProperty('com.wef.system.entity.Office', 'officeCode', officeCode.getValue(), {
			callback : function(result){
				if(result.length > 0){
					officeCode.setValue(result[0]);
				}
			}, async : false
		});
	},

	unhideAction : function() {
		this.topPanel.form.reset();
		this.store.load();
	}
});

Ext.onReady(function(){
	new RoleManager();
});